'use strict';

define(['services'], function (services) {
    services.solr.register('ConfigService', ['$resource', '$http', function ($resource, $http) {
        var resource = $resource('/rest/solr/config/:id', {id: '@id'}, {});

        resource.upload = function (data, callback) {
            var formData = new FormData();
            for(var key in data) {
                formData.append(key, data[key]);
            }
            $http({
                method: 'POST',
                url: '/rest/solr/config/upload',
                data: formData,
                headers: {'Content-Type': undefined},
                transformRequest: angular.identity
            }).success(function (data, status, headers, config) {
                if (callback != null) {
                    callback();
                }
            });
        };
        return resource;
    }]);
});